package com.purebang.spaceinvaders;

import java.awt.Rectangle;
import java.util.Random;

public class Projectile {
	
	public enum ProjectileType {
		strong,
		medium,
		weak
	};
	
	private final int HEIGHT = 12;
	private final int WIDTH = 8;
	private int ySpeed;
	private int power;
	private int ID;
	private ProjectileType type;
	private Rectangle hitbox;
	
	public Projectile(Rectangle enemyHitbox, int ID) {
		//We want to spawn the laser in the middle of the LaserCannon
		int x = enemyHitbox.x + ((int) enemyHitbox.width / 2);
		int y = enemyHitbox.y + Enemy.ENEMY_HEIGHT;
		hitbox = new Rectangle(x,y,WIDTH,HEIGHT);
		this.ID = ID;
		Random rand = new Random();
		//Spawn a random type of missile
		switch(rand.nextInt(3)) {
		case 0:
			//slow but strong strength projectile
			type = ProjectileType.strong;
			ySpeed = 3;
			power = 3;
			break;
		case 1:
			//medium speed and medium strength projectile
			type = ProjectileType.medium;
			ySpeed = 5;
			power = 2;
			break;
		case 2:
			type = ProjectileType.weak;
			ySpeed = 7;
			power = 1;
			break;
		}
	}
	
	public void update() {
		hitbox.y = hitbox.y + ySpeed;
	}

	public Rectangle getHitbox() {
		return hitbox;
	}
	
	public int getPower() {
		return power;
	}
	
	public ProjectileType getType() {
		return type;
	}
	
	public int getID() {
		return ID;
	}

}
